package jucP.Pdd0530;

import java.util.Random;

/**
 * @author : LdLtd
 * @Date : 2024/6/4
 * @Description:
 * 生成随机单词
 * 步骤
 * 1.定义包含所有字母的字符串
 * 2.生成随机长度
 * 3.随机选择字符
 * 4.拼接
 *
 */
public class RandomWordGenerator {
    static Random random=new Random();
    public static String getWord(){
        StringBuffer str=new StringBuffer();
        int n = random.nextInt(20)+3;
        for (int i = 0; i < n; i++) {
            str.append((char)('a'+random.nextInt(26)));
        }
        return str.toString();
    }
    public static String getWords(int n){
        StringBuffer str=new StringBuffer();
        for (int i = 0; i < n; i++) {
            str.append(getWord()+"\n");
        }
        return str.toString();
    }
    public static void main(String[] args) {
        System.out.println(getWord());
        System.out.println(getWords(10));
    }
}
